package com.xtianzhuang.www.aspect;

import java.lang.reflect.Method;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import com.xtianzhuang.www.annotation.Log;

/**
 * 
 * @author xtian.zhuang
 *
 */
@Aspect
@Component
public class LogAspect {
	@Pointcut("@annotation(com.xtianzhuang.www.annotation.Log)")
	public void logAspect() {

	}

	@Before("logAspect()")
	public void log(JoinPoint joinPoint) {
		Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
		if (method != null) {
			Log log = method.getAnnotation(Log.class);
			System.out.println(log.type());
		}
	}

}
